export const throttle = (func: Function, delay = 100) => {
  let inThrottle = false

  return (...args: any) => {
    if (!inThrottle) {
      func.apply(this, args)
      inThrottle = true
      setTimeout(() => {
        inThrottle = false
      }, delay)
    }
  }

  // return function (...args: any) {
  //   if (!inThrottle) {
  //     func.apply(this, args)
  //     inThrottle = true
  //     setTimeout(() => {
  //       inThrottle = false
  //     }, delay)
  //   }
  // }
}
